<?php
/**
 * Created by PhpStorm.
 * User: yanghe
 * Date: 2016/3/23
 * Time: 14:06
 */
namespace App\Http\Controllers\Test;
use App\Http\Controllers\Controller;
use Base\Student\Student;
use Illuminate\Support\Facades\Request;

class LoginController extends Controller
{
  public function login()
  {
      return view("student.login");
  }

    /**
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function _login()
    {
        $data = Request::only("user_name", "user_passwd");
        $result = Student::login($data["user_name"], $data["user_passwd"]);
        if (true == $result) {
            $semester = Student::_semester();
            $course = Student::_course();
            $inputData["semester"] = $semester;
            $inputData["course"] = $course;
            return view("student.main", $inputData);
        } else {
            echo "登录失败";
            return view("student.login");
        }
    }

        public function select()
        {
            $data=Request::only("course","semester");
            $student_id=Student::select_id();
            $course_id=Student::course_id($data["course"]);
            $semester_id=Student::semester_id($data["semester"]);
            $grade=Student::grade($semester_id,$course_id,$student_id);
            $inputData["grade"]=$grade;
            $inputData["data"]=$data;
            return view("student.res",$inputData);
        }


}